<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <my-input v-model="msg"></my-input>
        {{msg}}
    </div>
    <template id="myinput">
        <!-- 只能有一个根元素 -->
        <div>
            <input type="text" :value="value" @input="changeVal($event)">
        </div>
    </template>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>

        let myInput = {
            model: {
                prop: "value",
                event: 'input'
            },
            props: ['value'],
            template: '#myinput',
            methods: {
                changeVal(event) {
                    this.$emit("input", event.target.value)
                }    
            }
        }

        const app = new Vue({
            el: "#app",
            components: {
                myInput
            },
            data: {
                msg: "helloworld"
            }
        })
    </script>
</body>
</html>